package com.goldenautumn.prefabricate.activity.mall.adapter

import android.view.ViewGroup
import android.widget.ImageView
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.utils.loadImgUrl
import com.youth.banner.adapter.BannerAdapter
import com.youth.banner.holder.BannerImageHolder

class ImageBannerAdapter constructor(var data: List<String>) : BannerAdapter<String, BannerImageHolder>(data) {

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerImageHolder {
        val imageView = ImageView(parent?.context)
        val params = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
        imageView.layoutParams = params
        imageView.scaleType = ImageView.ScaleType.CENTER_CROP
        return BannerImageHolder(imageView)
    }

    override fun onBindView(holder: BannerImageHolder?, data: String?, position: Int, size: Int) {
        holder?.imageView?.loadImgUrl(data)
    }

}